<template>
  <div class="app-container">
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">基本信息</span>
    </div>
    <div class="table-layout">
      <el-row>
        <el-col :span="6" class="table-cell-title">机构名称</el-col>
        <el-col :span="6" class="table-cell-title">联系人</el-col>
        <el-col :span="12" class="table-cell-title">联系电话</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell">{{ course.deptName }}</el-col>
        <el-col :span="6" class="table-cell">{{ course.contactsName }}</el-col>
        <el-col :span="12" class="table-cell">{{ course.phone }}</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell-title">场馆数量</el-col>
        <el-col :span="6" class="table-cell-title" style="height:37px">合作状态</el-col>
        <el-col :span="12" class="table-cell-title" style="height:37px">合作起止时间</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell" style="font-size: 13px">{{ course.siteCount }}</el-col>
        <el-col :span="6" class="table-cell">{{ course.status_val }}</el-col>
        <el-col :span="12" class="table-cell">{{ course.startTime | formatDateTime }} 到 {{ course.endTime | formatDateTime }}</el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell-title">机构地址</el-col>
        <el-col :span="6" class="table-cell-title" style="height:37px"></el-col>
        <el-col :span="12" class="table-cell-title" style="height:37px"></el-col>
      </el-row>
      <el-row>
        <el-col :span="6" class="table-cell">{{ course.deptAddr }}</el-col>
        <el-col :span="6" class="table-cell"></el-col>
        <el-col :span="12" class="table-cell"></el-col>
      </el-row>
    </div>
    <div style="margin-top: 20px">
      <svg-icon icon-class="marker" style="color: #606266"></svg-icon>
      <span class="font-small">操作信息</span>
    </div>
    <div class="table-layout">
      <el-row>
        <el-col :span="4" class="table-cell-title">操作者</el-col>
        <el-col :span="6" class="table-cell-title">操作时间</el-col>
        <el-col :span="4" class="table-cell-title">操作前机构状态</el-col>
        <el-col :span="4" class="table-cell-title">操作后机构状态</el-col>
        <el-col :span="6" class="table-cell-title">备注</el-col>
      </el-row>
      <el-row v-for="(item,index) in list" :key="index">
        <el-col :span="4" class="table-cell">{{ item.operatorName }}</el-col>
        <el-col :span="6" class="table-cell">{{ item.updateTime | formatDateTime }}</el-col>
        <el-col :span="4" class="table-cell">{{ item.oldStatus | formatStr }}</el-col>
        <el-col :span="4" class="table-cell">{{ item.newStatus | formatStr }}</el-col>
        <el-col :span="6" class="table-cell">{{ item.remarks }}</el-col>
      </el-row>
    </div>
    <el-row type="flex" justify="end" style="margin-top: 20px">
      <el-col :span="2">
        <el-button @click="back">返回</el-button>
      </el-col>
    </el-row>

  </div>
</template>
<script>

import { umsServDeptById, serviceDeptLogList } from '@/api/servDept'
import { formatDate } from '@/utils/date'
export default {
  name: 'CourseList',
  data () {
    return {
      course: {},
      list: [],
      total: null,
      listLoading: false,
      status: {
        '01': '未合作',
        '02': '合作中',
        '03': '已停止',
        '04': '冻结'
      }
    }
  },
  created () {
    umsServDeptById({ id: this.$route.query.id }).then(response => {
      this.course = response.data
      var status1 = response.data.status
      this.course.status_val = this.status[status1]
    })

    serviceDeptLogList({ deptId: this.$route.query.id,
      pageNum: 1,
      pageSize: 200 }).then(response => {
      this.list = response.data.list
    })
  },
  filters: {
    formatStr (status) {
      if (status == null || status === '') {
        return 'N/A'
      }
      return {
        '01': '未合作',
        '02': '合作中',
        '03': '已停止',
        '04': '冻结'
      }[status]
    },
    formatDateTime (time) {
      if (time == null || time === '') {
        return 'N/A'
      }
      const date = new Date(time)
      return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
    }
  },
  methods: {
    back () {
      this.$router.go(-1)
    }

  }
}
</script>
<style scoped>
  .app-container {
    width: 80%;
    margin: 20px auto;
  }

  .table-layout {
    margin-top: 20px;
    border-left: 1px solid #DCDFE6;
    border-top: 1px solid #DCDFE6;
  }

  .table-cell {
    height: 60px;
    line-height: 40px;
    border-right: 1px solid #DCDFE6;
    border-bottom: 1px solid #DCDFE6;
    padding: 10px;
    font-size: 14px;
    color: #606266;
    text-align: center;
    overflow: hidden;
  }

  .table-cell-title {
    border-right: 1px solid #DCDFE6;
    border-bottom: 1px solid #DCDFE6;
    padding: 10px;
    background: #F2F6FC;
    text-align: center;
    font-size: 14px;
    color: #303133;
  }

  .coursePic {
    margin-top: 20px;
    max-width: 100%;
  }
</style>
